#include"stc.h"
#include"key_deal.h"
#include"typedef.h"
#include"IO_config.h"
#include"wireless.h"

bit key_press_flag = 0;

void ReadKey(void)
{
	INT8U i = 0;
	static int keyCount[TOTAL_KEY] ={0};

	if (IN0==0)	  
	{keyCount[0]++;}
	else {keyCount[0]=0;}	
	if (IN1==0)  
	{keyCount[1]++;}
	else{keyCount[1]=0;}	
	if (IN2==0) 
	{keyCount[2]++;}
	else{keyCount[2]=0;}
	if (IN3==0)	  
	{keyCount[3]++;}
	else {keyCount[3]=0;}	

	
	if(keyCount[0] > 8)
	{
		keyCount[0]=0;
		keyPressed[0] = 1;
		key_press_flag = 1;
	}
	if(keyCount[1]>8)
	{
		keyCount[1]=0;
		keyPressed[1] = 1;
		key_press_flag = 1;
	}
	if(keyCount[2]>8)
	{
		keyCount[2]=0;
		keyPressed[2] = 1;
		key_press_flag = 1;
	}
	if(keyCount[3]>8)
	{
		keyCount[3]=0;
		keyPressed[3] = 1;
		key_press_flag = 1;
	}
	
/*
	if(keyCount[0]>8)
	{
		keyCount[0]=0;
		keyPressed[0] = 1;
//		OUT8 = ~OUT8;
		key_press_flag = 1;
	}
	if(keyCount[1]>8)
	{
		keyCount[1]=0;
		keyPressed[1] = 1;
//		OUT9 = ~OUT9;
		key_press_flag = 1;
	}
		if(keyCount[2]>8)
	{
		keyCount[2]=0;
		keyPressed[2] = 1;
//		OUT10 = ~OUT10;
		key_press_flag = 1;
	}
		if(keyCount[3]>8)
	{
		keyCount[3]=0;
		keyPressed[3] = 1;
//		OUT11 = ~OUT11;
		key_press_flag = 1;
	}
*/
}
